/*

 Program housekeeping.sas assigns directory names, creates two simple macros for check merges and duplicates.

 Kumler, Verhoogen, Frias "Enlisting Employees ..." REStat forthcoming

*/


* Housekeeping;

options nodate ls=80 ps=100 nocenter;
title;

*** sas libnames;

libname working '/compliance/work';
libname tmp '/compliance/tmp/';

*** macros to hold directories -- adjust for local operating system;
    
%let working = /home/compliance/work/;
%let tmp =     /home/compliance/tmp/;

%let imss = /home/compliance/imss/;
%let eneu = /home/compliance/eneu/datos/website;
%let precios=/home/compliance/precios/;
%let concordances=/home/compliance/concordances/;
%let code=/home/compliance/code/;

*** Define macros ***;
%macro checkmer(mergeddata, onename, twoname);
    data checkmer1;
        set &mergeddata;
        where &onename=1 and &twoname=1;
        if _N_=1 then put 'appearing in both datasets';
    run;
    data checkmer2;
        set &mergeddata;
        where &onename=1 and &twoname=.;
        if _N_=1 then put "appearing only in &onename";
    run;
    data checkmer3;
        set &mergeddata;
        where &onename=. and &twoname=1;
        if _N_=1 then put "appearing only in &twoname";
    run;
%mend checkmer;

%macro checkdup(dataset, contvar, indvar);
    proc means data=&dataset. noprint;
        by &contvar;
        var &indvar;
        output out=&dataset.out n=count;
    run;
    data checkdup;
        set &dataset.out;
        where count>1;
    run;
    proc print data=checkdup;
    run;
%mend checkdup;
